#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int MAXN(1E5 + 5);
int m[MAXN], dp[MAXN];
int main() {
    ios::sync_with_stdio(0);
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> m[i];
    for (int i = 1; i <= n; i++) {
        int maxium = 0;
        for (int j = 0; j < i; j++) if (m[j] < m[i]) maxium = max(maxium, dp[j]);
        dp[i] = maxium + 1;
    }
    int maxium = 0;
    for (int i = 1; i <= n; i++) maxium = max(maxium, dp[i]);
    cout << n - maxium;
    return 0;
}
